package com.swf.seed.algorithms.problem;

/**
 * ClassName: PascalsTriangle <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Desc: 杨辉三角，又称贾宪三角形，帕斯卡三角形，是二项式系数在三角形中的一种几何排列. <br/>
 *    	 1	<br/>
 * 		 1	 1	<br/>
 * 	  1  2   1	<br/>
 * 	1	 3	 3	 1	<br/>
 * 1  4  6   4  1	<br/>
 *
 * date: 2015-1-20 上午10:59:39 <br/>
 *
 * @author shenwf10476
 * @version
 * @since JDK 1.6
 */
public class PascalsTriangle {
	void paint(int row){
		int[][] yh = new int[row][row];
		for (int i=0;i<row;i++){
			yh[i][0] = 1;
			yh[i][i] = 1;
		}
		for (int i=2;i<row;i++){
			for (int j=1; j<i; j++){
				yh[i][j] = yh[i-1][j-1]+yh[i-1][j];
			}
		}
		for (int i=0;i<row;i++){
			for (int j=0;j<=i;j++){
				System.out.print(yh[i][j]+"\t");
			}
			System.out.println();
		}
	}

	public static void main(String[] args) {
		new PascalsTriangle().paint(6);
	}
}
